/**
 * 
 */
package com.orisper.esb.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.orisper.dao.Bm_productDao;
import com.orisper.model.ApiMessage;
import com.orisper.utils.ApiConstants;
import com.orisper.utils.exception.ApiException;

import aos.framework.core.dao.SqlDao;
import aos.framework.core.typewrap.Dto;
import aos.framework.core.typewrap.Dtos;
import aos.framework.core.utils.AOSJson;
import aos.framework.core.utils.AOSUtils;

/**
 * @author Administrator
 *
 */
@Service
public class ApiFrontService {

	@Autowired
	SqlDao sqlDao;
	
	@Autowired
	Bm_productDao bm_productDao;
	
	
	/**
	 * 查询首页轮播图，副轮播图
	 * @param inDto
	 * @return
	 * @throws ApiException
	 */
	public ApiMessage getFrontPicUrl(Dto inDto) throws ApiException{
		ApiMessage msg=new ApiMessage();
		Dto dto = sqlDao.selectDto("Api.getIndexPic",null);
		if(AOSUtils.isEmpty(dto)){
		  throw new ApiException(ApiConstants.REQ_ERROR, ApiConstants.MSG_PARAM_MISS);	
		}
		msg.setCode(ApiConstants.REQ_SUCCESS);
		msg.setMessage(ApiConstants.MSG_SUCCESS);
		msg.setData(AOSJson.toJson(dto));
		return msg;
	}
	
	/**
	 * 查询首页产品
	 * @param inDto
	 * @return
	 * @throws ApiException
	 */
	public ApiMessage getFrontProduct(Dto inDto) throws ApiException{
		ApiMessage msg=new ApiMessage();
		Dto rDto=Dtos.newDto();
		List<Dto> speList = sqlDao.list("Api.getSpeList",null);
		List<Dto> recList = sqlDao.list("Api.getRecList",null);
		rDto.put("speList", speList);
		rDto.put("recList", recList);
		msg.setCode(ApiConstants.REQ_SUCCESS);
		msg.setMessage(ApiConstants.MSG_SUCCESS);
		msg.setData(AOSJson.toJson(rDto));
		return msg;
	}
	
}
